package edu.isistan.metamodel;

import java.util.Vector;

/**
 * Represents a complex datatype
 */
public class Composed extends DataType {
	
	private Vector<DataType> dataTypes = new Vector<DataType>();
	
	public Composed() {
	}
	
	public Composed(String name, String type, Vector<DataType> dataTypes, String doc) {
		super(name, type, doc);
		this.dataTypes=dataTypes;
		for (DataType dataType : dataTypes) {
			dataType.setContainedIn(this);
		}
	}

	public Vector<DataType> getDataTypes() {
		return dataTypes;
	}

	public void setDataTypes(Vector<DataType> dataTypes) {
		this.dataTypes = dataTypes;
	}
	
	public void addDatatype(DataType dataType) {
		if (this.dataTypes != null)
			this.dataTypes.add(dataType);
	}

	@Override
	public boolean isPrimitive() {
		return false;
	}

	@Override
	public void setCardinality(int cardinality) {
		this.cardinality = cardinality;
		for(DataType d : dataTypes)
			d.setCardinality(cardinality);
	}
	
	@Override
	public boolean isCollection() {
			return false;
	}
	@Override
	public boolean isWrapper() {
		return false;
	}

	@Override
	public String toString() {
		String result = super.toString();
		return result;
	}

	@Override
	public boolean isCompoused() {
		return true;
	}

	@Override
	public boolean isArray() {
		return false;
	}

	@Override
	public String getPrettyPrintType() {
		return getType();
	}
}
